home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / jed10.zip / INFO.ASM < prev    next >
Assembly Source File  |  1993-02-26  |  19KB  |  403 lines

  1. ;---------------------------------------------------------------
  2. ;                          INFO.ASM
  3. ;     Utility to determine and report system parameters
  4. ;
  5. ;                                      by Jeff Duntemann
  6. ;                                      MASM/TASM
  7. ;                                      Last update 12/26/89
  8. ;---------------------------------------------------------------
  9.  
  10. INCLUDE MYLIB.MAC               ; Load in macro library
  11.  
  12. ;----------------------------|
  13. ;    BEGIN STACK SEGMENT     |
  14. ;----------------------------|
  15. MYSTACK    SEGMENT STACK        ; STACK word ensures loading of SS by DOS
  16.  
  17.            DB      64 DUP ('STACK!!!') ; This reserves 512 bytes for the stack
  18.  
  19. MYSTACK    ENDS
  20. ;----------------------------|
  21. ;     END STACK SEGMENT      |
  22. ;----------------------------|
  23.  
  24. ;----------------------------|
  25. ;     BEGIN DATA SEGMENT     |
  26. ;----------------------------|
  27. MyData     SEGMENT
  28.  
  29. ;---------------------------------------------------------------
  30. ; DISPLAY INFORMATION VARIABLES
  31. ;
  32. ; The following block of variables all relate to the video
  33. ; system and are initialized by the VidCheck procedure:
  34. ;---------------------------------------------------------------
  35. DispType   DB      0       ; Code for display adapter type
  36. VidOrigin  DW      0       ; Offset for FAR pointer to refresh buffer
  37. VidSegment DW      0B000H  ; Segment of installed display buffer
  38. VisibleX   DB      80      ; Number of columns on screen
  39. VisibleY   DB      25      ; Number of lines on screen
  40. VidBufSize DW      4000    ; Default to 25 X 80 X 2 (char & attribute)
  41. FontSize   DB      8       ; Either 8, 14, or 16; default to 8
  42. BordName   DW      ?       ; NEAR pointer to name string of installed board
  43. ; 18H = 24D; 4FH = 79D; Combined 0-based X,Y of 80 x 25 screen LR corner:
  44. LRXY       DW      184FH
  45.  
  46. ;---------------------------------------------------------------
  47. ; DISPLAY ADAPTER INFORMATION LOOKUP TABLE
  48. ;
  49. ; This is the lookup table containing information on all legal
  50. ; display adapters.  The first field in each element is a 26-
  51. ; character string containing a brief description of the
  52. ; adapter.  The next field is the segment of the video refresh
  53. ; buffer.  The last three fields are the number of screen lines
  54. ; an adapter displays when the 8-pixel, 14-pixel, and 16-pixel
  55. ; fonts are loaded, respectively.  Note that not all adapters
  56. ; support all fonts, but a screen line count is given for all
  57. ; three fonts for all adapter types.  Illegal combinations will
  58. ; not be accessed.
  59. ;---------------------------------------------------------------
  60. VidInfoTbl DB      'No adapter identified      '    ; Code 0
  61.            DW      0B000H
  62.            DB      25,25,25
  63.            DB      'Monochrome Display Adapter '    ; Code 1
  64.            DW      0B000H
  65.            DB      25,25,25
  66.            DB      'Color Graphics Adapter     '    ; Code 2
  67.            DW      0B800H
  68.            DB      25,25,25
  69.            DB      'Code 3: Undefined          '    ; Code 3
  70.            DW      0B000H
  71.            DB      25,25,25
  72.            DB      'EGA with color monitor     '    ; Code 4
  73.            DW      0B800H
  74.            DB      43,25,25
  75.            DB      'EGA with mono monitor      '    ; Code 5
  76.            DW      0B000H
  77.            DB      43,25,25
  78.            DB      'Code 6: Undefined          '    ; Code 6
  79.            DW      0B000H
  80.            DB      25,25,25
  81.            DB      'VGA with mono monitor      '    ; Code 7
  82.            DW      0B000H
  83.            DB      50,27,25
  84.            DB      'VGA with color monitor     '    ; Code 8
  85.            DW      0B800H
  86.            DB      50,27,25
  87.            DB      'Code 9: Undefined          '    ; Code 9
  88.            DW      0B000H
  89.            DB      25,25,25
  90.            DB      'MCGA with digital color    '    ; Code 0AH
  91.            DW      0B800H
  92.            DB      25,25,25
  93.            DB      'MCGA with monochrome       '    ; Code 0BH
  94.            DW      0B000H
  95.            DB      25,25,25
  96.            DB      'MCGA with analog color     '    ; Code 0CH
  97.            DW      0B800H
  98.            DB      25,25,25
  99.  
  100. Digits     DB      '0123456789ABCDEF' ; Lookup table for numeric/string conv.
  101.  
  102. ;---------------------------------------------------------------
  103. ; These two variables are screen-clear "atoms" useable by the
  104. ; Clear macro.  The high byte is the display attribute, while
  105. ; the low byte is the character with which Clear fills the
  106. ; video refresh buffer to clear the screen.
  107. ;---------------------------------------------------------------
  108. HToneAtom  DW      07B0H          ; Clears screen to halftone pattern
  109. ClearAtom  DW      0720H          ; Clears screen to blanks
  110.  
  111. ;---------------------------------------------------------------
  112. ; This is where all predefined string variables are stored.
  113. ;---------------------------------------------------------------
  114. CRLF       DB      0DH,0AH        ; Newline string
  115. IDString   DB      '>>>INFO V1.0'
  116. LIDString  EQU     $-IDString
  117. AuthorStr  DB      '   by Jeff Duntemann'
  118. LAuthorStr EQU     $-AuthorStr
  119. VidIDStr   DB      '   The installed video board is: '
  120. LVidIDStr  EQU     $-VidIDStr
  121. OrgIDStr   DB      '   The segment of the video refresh buffer is: '
  122. LOrgIDStr  EQU     $-OrgIDStr
  123. FontSzStr  DB      '   The size of the current text font is: '
  124. LFontSzStr EQU     $-FontSzStr
  125. ScrnLnStr  DB      '   The number of lines currently on the screen is: '
  126. LScrnLnStr EQU     $-ScrnLnStr
  127. BufSizStr  DB      '   The size of the refresh buffer in bytes is: '
  128. LBufSizStr EQU     $-BufSizStr
  129. DigitStr   DB      '       '
  130. LDigitStr  EQU     $-DigitStr
  131.  
  132. MyData     ENDS
  133. ;----------------------------|
  134. ;      END DATA SEGMENT      |
  135. ;----------------------------|
  136.  
  137. ;----------------------------|
  138. ;     BEGIN CODE SEGMENT     |
  139. ;----------------------------|
  140. MyProg     SEGMENT
  141.  
  142.            ASSUME CS:MyProg,DS:MyData
  143. Main       PROC
  144.  
  145. Start:     ; This is where program execution begins:
  146.            mov  AX,MyData     ; Set up our own data segment address in DS
  147.            mov  DS,AX         ; Can't load segment reg. directly from memory
  148.  
  149.            call VidCheck      ; Initialize all video information variables
  150.  
  151.            Clear VidOrigin,ClearAtom,VidBufSize  ; Clear the screen
  152.  
  153.            ; Here we display the name of the program and its author:
  154.            Writeln IDString,LIDString      ; Display the program name
  155.            Writeln AuthorStr,LAuthorStr    ; display the author name
  156.            Newline
  157.  
  158.            ; Here we display the name of the installed video board:
  159.            Write VidIDStr,LVidIDStr        ; Display the intro string
  160.            mov BX,1         ; Select DOS file handle 1: Standard Output
  161.            mov CX,27        ; The name strings are 27 bytes long
  162.            mov DX,BordName  ; The string address is stored in BordName
  163.            mov AH,40H       ; Service 40H: Write string to file
  164.            int 21H          ; Call DOS to display to Standard Output
  165.            Newline
  166.  
  167.            ; Here we display the segment address of the refresh buffer:
  168.            Write OrgIDStr,LOrgIDStr     ; Display the intro string
  169.            mov  AX,VidSegment ; AX gets the value to convert to a string
  170.            lea  SI,DigitStr   ; String equivalent is written to DigitStr
  171.            call Word2Str      ; Do the actual string conversion
  172.            PokeChar DigitStr,'H',4   ; Append 'H' on the end of the string
  173.            Writeln DigitStr,5 ;  and display the string equivalent
  174.  
  175.            ; Here we display the size of the current text font:
  176.            Write FontSzStr,LFontSzStr   ; Display the intro string
  177.            mov  AL,FontSize   ; AL gets the value to convert to a string
  178.            lea  SI,DigitStr   ; String equivalent is written to DigitStr
  179.            call Byte2Str      ; Do the actual string conversion
  180.            PokeChar DigitStr,'H',2   ; Append 'H' on the end of the string
  181.            Writeln DigitStr,3 ;  and display the string equivalent
  182.  
  183.            ; Here we display the number of lines on the screen:
  184.            Write ScrnLnStr,LScrnLnStr
  185.            mov  AL,VisibleY   ; AL gets the value to convert to a string
  186.            lea  SI,DigitStr   ; String equivalent is written to DigitStr
  187.            call Byte2Str      ; Do the actual string conversion
  188.            PokeChar DigitStr,'H',2   ; Append 'H' on the end of the string
  189.            Writeln DigitStr,3 ;  and display the string equivalent
  190.  
  191.            ;Finally, we display the size of the video refresh buffer:
  192.            Write BufSizStr,LBufSizStr     ; Display the intro string
  193.            mov  AX,VidBufSize ; AX gets the value to convert to a string
  194.            lea  SI,DigitStr   ; String equivalent is written to DigitStr
  195.            call Word2Str      ; Do the actual string conversion
  196.            PokeChar DigitStr,'H',4   ; Append 'H' on the end of the string
  197.            Writeln DigitStr,5 ;  and display the string equivalent
  198.            Newline
  199.  
  200.            mov  AH,4CH        ; Terminate process DOS service
  201.            mov  AL,0          ; Pass this value back to ERRORLEVEL
  202.            int  21H           ; Control returns to DOS
  203.  
  204. Main       ENDP
  205.  
  206.  
  207. ;---------------------------------------------------------------
  208. ;   Byte2Str  --  Converts a byte passed in AL to a string at
  209. ;                 DS:SI
  210. ;   Last update 3/8/89
  211. ;
  212. ;   1 entry point:
  213. ;
  214. ;   Byte2Str:
  215. ;      Caller must pass:
  216. ;      AL : Byte to be converted
  217. ;      DS : Segment of destination string
  218. ;      SI : Offset of destination string
  219. ;
  220. ;      This routine converts 8-bit values to 2-digit hexadecimal
  221. ;      string representations at DS:SI.
  222. ;---------------------------------------------------------------
  223.  
  224. Byte2Str   PROC
  225.            mov DI,AX                ; Duplicate byte in DI
  226.            and DI,000FH             ; Mask out high 12 bits of DI
  227.            mov BX,OFFSET Digits     ; Load offset of Digits into DI
  228.            mov AH,BYTE PTR [BX+DI]  ; Load digit from table into AH
  229.            mov [SI+1],AH            ;   and store digit into string
  230.            xor AH,AH                ; Zero out AH
  231.            mov DI,AX                ; And move byte into DI
  232.            shr DI,1                 ; Shift high nybble of byte to
  233.            shr DI,1                 ;   low nybble
  234.            shr DI,1
  235.            shr DI,1
  236.            mov AH,BYTE PTR [BX+DI]  ; Load digit from table into AH
  237.            mov [SI],AH              ;   and store digit into string
  238.            ret                      ; We're done--go home!
  239. Byte2Str   ENDP
  240.  
  241.  
  242. ;---------------------------------------------------------------
  243. ;   Word2Str  --  Converts a word passed in AX to a string at
  244. ;                 DS:SI
  245. ;   Last update 3/8/89
  246. ;
  247. ;   1 entry point:
  248. ;
  249. ;   Word2Str:
  250. ;      Caller must pass:
  251. ;      AX : Word to be converted
  252. ;      DS : Segment of destination string
  253. ;      SI : Offset of destination string
  254. ;---------------------------------------------------------------
  255.  
  256. Word2Str   PROC
  257.            mov  CX,AX       ; Save a copy of convertee in CX
  258.            xchg AH,AL       ; Swap high and low AX bytes to do high first
  259.            call Byte2Str    ; Convert AL to string at DS:SI
  260.            add  SI,2        ; Bump SI to point to second 2 characters
  261.            mov  AX,CX       ; Reload convertee into AX
  262.            call Byte2Str    ; Convert AL to string at DS:SI
  263.            ret              ; And we're done!
  264. Word2Str   ENDP
  265.  
  266.  
  267. ;---------------------------------------------------------------
  268. ;   VidCheck  --  Identifies display board & display parameters
  269. ;   Last update 3/16/89
  270. ;
  271. ;   1 entry point:
  272. ;
  273. ;   VidCheck:
  274. ;      Caller need pass no parameters.
  275. ;      VidCheck identifies the installed display board by
  276. ;      calling DispID.  It then calculates numerous display
  277. ;      information values, which it then stores in the block
  278. ;      of display information variables in the data segment.
  279. ;---------------------------------------------------------------
  280.  
  281. VidCheck   PROC
  282.            ; First task is to figure out which board is on the bus:
  283.            call DispID        ; Ask BIOS for adapter code; returns in AL
  284.            mov  DispType,AL   ; Store display adapter code in DispType
  285.  
  286.            ; Next we determine the font size currently in force:
  287.            cmp  AL,0AH        ; See if board is an MCGA
  288.            jl   TryOld        ; If less than code 0AH, it's not an MCGA
  289.            mov  FontSize,16   ; MCGA supports *only* 16 pixel text font
  290.            jmp  GetName       ; Jump ahead to look up adapter name string
  291. TryOld:    cmp  DispType,1    ; Is the display adapter code 1, for MDA?
  292.            jne  TryCGA        ; If not, go test for CGA code 2
  293.            mov  FontSize,14   ; MDA uses *only* 14-pixel text font
  294.            jmp  GetName       ; Jump ahead to look up adapter name string
  295. TryCGA:    cmp  DispType,2    ; Is the display adapter code 2, for CGA?
  296.            jne  TryVGA        ; If not, go test for EGA/VGA font size
  297.            mov  FontSize,8    ; CGA uses *only* 8-pixel text font
  298.            jmp  GetName       ; Jump ahead to look up adapter name string
  299. TryVGA:    mov  AH,11H        ; Select VIDEO Get Font Information subservice
  300.            mov  AL,30H        ;   requires AH = 11H and AL = 30H
  301.            mov  BH,0          ; 0 = Get info about current font
  302.            int  10H           ; Call VIDEO
  303.            mov  FontSize,CL   ; Font size in pixels is returned in CL
  304.  
  305.            ; Next we get the name string for the board from the info table:
  306. GetName:   mov  AL,DispType   ; Load display adapter code into AL
  307.            xor  AH,AH         ; Zero AH so we don't copy trash into DI
  308.            mov  DI,AX         ; Copy AX (with code in AL) into DI
  309.            mov  CL,5          ; We must shift the code 5 bits to mult. by 32
  310.            shl  DI,CL         ; Multiply code by 32 to act as table index
  311.            lea  BX,VidInfoTbl ; Load address of origin table into BX
  312.            mov  BordName,BX   ; Save pointer to video info. table in BordName
  313.            add  Bordname,DI   ; Add offset into table to right element
  314.  
  315.            ; Next we get the refresh buffer segment from the table:
  316.            mov  AX,[BX+DI+27] ; Index into table past name string to segment
  317.            mov  VidSegment,AX ; Store segment from table to VidSegment variable
  318.  
  319.            ; Here we calculate the number of lines on-screen from font size:
  320.            xor  AH,AH         ; Make sure AH has no trash in it
  321.            mov  AL,FontSize   ; Load the font size in pixels into AL
  322.            cmp  AL,8          ; Is it the 8-pixel font?
  323.            jne  Try14         ; If not, try the 14-pixel font
  324.            mov  AL,1          ; The 8-pixel font is table offset 1
  325.            jmp  ReadLns       ; Jump ahead to read screen lines from table
  326. Try14:     cmp  AL,14         ; Is it the 14-pixel font?
  327.            jne  Do16          ; If not, it has to be the 16-pixel font
  328.            mov  AL,2          ; The 14-pixel font is table offset 2
  329.            jmp  ReadLns       ; Jump ahead to read screen lines from table
  330. Do16:      mov  AL,3          ; The 16-pixel font is table offset 3
  331. ReadLns:   add  DI,AX         ; Add font size offset to table element offset
  332.            mov  AL,[BX+DI+28] ; Load the screen lines value from the table
  333.            mov  VisibleY,AL   ;  and store it in the VisibleY variable
  334.            mov  AH,VisibleX   ; Load the screen columns value to AH
  335.            xchg AH,AL         ; Exchange AH & AL for 0-basing
  336.            dec  AL            ; Subtract one from column count for 0-basing
  337.            dec  AH            ; Subtract one from line count for zero-basing
  338.            mov  LRXY,AX       ; And store 0-based X,Y word into LRXY variable
  339.  
  340.            ; Finally, we calculate the size of the refresh buffer in bytes:
  341.            mov  AL,VisibleY   ; We multiply screen lines time screen columns
  342.            mul  VisibleX      ;  times 2 (for attributes) to get buffer size
  343.            shl  AX,1          ; Multiply lines * columns by 2
  344.            mov  VidBufSize,AX ; Store refresh buffer size in VidBufSize
  345.  
  346.            ret                ; Return to caller
  347. VidCheck   ENDP
  348.  
  349.  
  350. ;---------------------------------------------------------------
  351. ;   DispID  --  Identifies the installed display adapter
  352. ;   Last update 3/8/89
  353. ;
  354. ;   1 entry point:
  355. ;
  356. ;   DispID:
  357. ;      Caller passes no parameters
  358. ;      Routine returns a code value in AX.
  359. ;      The codes are these:
  360. ;      0 : Adapter is unknown; recommend aborting
  361. ;      1 : MDA (Monochrome Display Adapter)
  362. ;      2 : CGA (Color Graphics Adapter)
  363. ;
  364. ;---------------------------------------------------------------
  365.  
  366. DispID     PROC
  367.            mov  AH,1AH      ; Select PS/2 Identify Adapter Service
  368.            xor  AL,AL       ; Select Get Combination Code Subservice (AL=0)
  369.            int  10H         ; Call VIDEO
  370.            cmp  AL,1AH      ; If AL comes back with 1AH, we have a PS/2
  371.            jne  TryEGA      ; If not, jump down to test for the EGA
  372.            mov  AL,BL       ; Put Combination Code into AL
  373.            ret              ;   and go home!
  374. TryEGA:    mov  AH,12H      ; Select EGA Alternate Function
  375.            mov  BX,10H      ; Select Get Configuration Information subservice
  376.            int  10H         ; Call VIDEO
  377.            cmp  BX,10H      ; If BX comes back unchanged, EGA is *not* there
  378.            je   OldBords    ; Go see whether it's an MDA or CGA
  379.            cmp  BH,0        ; If BH = 0, it's an EGA/color combo
  380.            je   EGAColor    ;   otherwise it's EGA/mono
  381.            mov  AL,5        ; Store code 5 for EGA mono
  382.            ret              ;   and go home!
  383. EGAColor:  mov  AL,4        ; Store code 4 for EGA color
  384.            ret              ;   and go home!
  385. OldBords:  int  11H         ; Call Equipment Configuration interrupt
  386.            and  AL,30H      ; Mask out all but bits 4 & 5
  387.            cmp  AL,30H      ; If bits 4 & 5 are both =1, it's an MDA
  388.            jne  CGA         ;   otherwise it's a CGA
  389.            mov  AL,1        ; Store code 1 for MDA
  390.            ret              ;   and go home!
  391. CGA:       mov  AL,2        ; Store code 2 for CGA
  392.            ret              ;   and go home!
  393. DispID     ENDP
  394.  
  395.  
  396. MyProg     ENDS
  397.  
  398. ;----------------------------|
  399. ;      END CODE SEGMENT      |
  400. ;----------------------------|
  401.  
  402.            END Start    ; The procedure named Start becomes the main program
  403.